/**
 * 
 */
package com.jzweb.springbootmail.web;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jzweb.springbootmail.service.MailService;

/**
 * @author 030998
 *
 */
@Controller
@RequestMapping("/mail")
public class MailController {
	@Autowired
	private MailService mailService;

	@RequestMapping("/send")
	public void list() {
		List<String> files = new ArrayList<String>();
		//files.add("C:\\Users\\030998\\Desktop\\Desktop大福晋.rar");
		//files.add("C:\\Users\\030998\\Desktop\\备件修复网络配置.pptx");
		
		String content = "<h3>\r\n"
				+ "	<strong>你好！</strong>\r\n"
				+ "</h3>\r\n"
				+ "<p>\r\n"
				+ "	&nbsp; &nbsp; &nbsp; &nbsp;这里是拉卡拉<span style=\"background-color:#FFE500;\">扣税的，就拉开建设的，艾丽卡是觉得</span>，卢卡斯拉<span style=\"color:#E53333;\">开点距离开发的离开家离开电</span>视机分厘卡就类似的看法，，考虑实际得分宽九点十六分看见了肯定是积分立刻决定是否了宽九点十六分看就拉开建设的发距离喀什酱豆腐立刻几十块的浪费记录卡撒旦解放拉开圣诞节分厘卡圣诞节发蓝底色解放了。<img src=\"http://kindeditor.net/ke4/plugins/emoticons/images/13.gif\" border=\"0\" alt=\"\" />\r\n"
				+ "</p>\r\n"
				+ "<p>\r\n"
				+ "	<ol>\r\n"
				+ "		<li>\r\n"
				+ "			<strong>卢卡斯的</strong>\r\n"
				+ "		</li>\r\n"
				+ "		<li>\r\n"
				+ "			<strong>阿三就大声的</strong>\r\n"
				+ "		</li>\r\n"
				+ "		<li>\r\n"
				+ "			<strong>啊是大</strong>\r\n"
				+ "		</li>\r\n"
				+ "		<li>\r\n"
				+ "			<strong>阿三d啊是大</strong>\r\n"
				+ "		</li>\r\n"
				+ "	</ol>\r\n"
				+ "</p>";
		
		mailService.sendAttachmentsMail("durandal1981@126.com", "测试出", content, files);
	}
	
	@RequestMapping("/rec")
	@ResponseBody
	public String receive() {
		try {
			mailService.receiveMail();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "ok";
	}
	
	@RequestMapping("/del/{uid}")
	@ResponseBody
	public String delMail(@PathVariable("uid") long uid) {
		long[] uids = new long[1];
		uids[0] = uid;
		
		mailService.deleteMail(uids);
		return "ok";
	}
	
	
}
